package com.dong.webtest;

/**
 * @author dengxiudong
 * @Date 2025/4/14 下午5:48
 */
public class SimpleCipher {
    // private static final long KEY = 0x123456789ABCDEFL; // 示例密钥
    private static final long KEY = 0x56895669889ABEFL; // 示例密钥

    public static String encrypt(String number) {
        long num = Long.parseLong(number);
        return String.format("%019d", num ^ KEY);
    }

    public static String decrypt(String cipher) {
        return encrypt(cipher); // XOR可逆
    }

    public static void main(String[] args) throws Exception
    {
        // String plainText = "1234567890123456789";
        String plainText = "6994567890123456789";
        String cipherText = encrypt(plainText);
        System.out.println("Plain text: " + plainText);
        System.out.println("Cipher text: " + cipherText);
        System.out.println("Decrypted text: " + decrypt(cipherText));
    }
}

